<?php
/**
 * 文章控制器
 * Created		: 2012-10-09
 * Modified		: 2012-10-09
 * @link		: http://www.dota100.com
 * @copyright	: (C) 2012 dota100.com 
 * @author		: Joseph Chen (chenliq@gmail.com)
 */
class Controller_Article extends Controller
{
	/**
	 * 文章表
	 * @var string
	 */
	public $tbl = 'article';
	
	/**
	 * 控制器载入后执行
	 */
	public function initialize()
	{
		
	}
	
	/**
	 * 列表
	 * @see Controller::index()
	 */
	public function index() 
	{
		$mo = new Model_Article();
		$options = array(
			'has_page'	=> true,
			'status'	=> 1,
			'limit'		=> 20
		);
		if (isset($_GET['game_id'])) {
			$options['game_id'] = $_GET['game_id'];
		}
		if (isset($_GET['cid'])) {
			$options['cid'] = $_GET['cid'];
		}
		if (isset($_GET['post_time'])) {
			$options['post_time'] = $_GET['post_time'];
		}
		if (isset($_GET['keyword'])) {
			$options['keyword'] = $_GET['keyword'];
		}
		$this->list = $mo->getList($options);
		$this->pagePanel = $mo->pagePanel;
	}
	
	/**
	 * 获取单篇文章信息
	 */
	public function view()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->display('view404');
		}
		
		$mo = new Model_Article();
		$this->detail = $mo->read($_GET['id']);
		
		$this->html_cache_file = 'a/'.String::idMath62Code($_GET['id']).'.html';
		echo $this->html_cache_file;
		return false;
	}
}